package org.pearl.springbootsecurity.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.pearl.springbootsecurity.demo.dao.UserMapper;
import org.pearl.springbootsecurity.demo.entity.User;
import org.pearl.springbootsecurity.demo.pojo.UserInfoDO;
import org.pearl.springbootsecurity.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author td
 * @since 2021-07-02
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public User getUserByName(String username) {
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getUserName, username);
        return getOne(queryWrapper);
    }

    @Override
    public UserInfoDO getUserInfoByName(String username) {
        return userMapper.getUserInfoByUserName(username);
    }
}
